﻿
function UI(){
	
	this.mask = null;
	this.MsgWin = null;
	this.centerObj =function(o,x,y){
		var S = new MyScreen();
		S = S.ScreenSize();
		o.style.left = ((S.w+x-parseInt(o.offsetWidth))/2)+"px";
		o.style.top = ((S.h+y-parseInt(o.offsetHeight))/2)+"px";
	}
	this.createMsgWin = function(id,w,h){
		id = id?id:"OQSS_MsgWin";
		var div = document.createElement("div");
		div.id = id;
		div.className = "OQSS_MsgWin shadow";
		document.body.appendChild(div);
		div.style.width = w+"px";
		div.style.height = h+"px";
		this.centerObj(div,10,0);
		this.MsgWin = div;
	}
	this.initMask = function(id){
		var S = new MyScreen();
		S = S.ScreenSize();
		id = id?id:"OQSS_Mask";
		var div = document.createElement("div");
		div.id = id;
		div.className = "OQSS_Mask";
		document.body.appendChild(div);
		div.style.width = S.w+"px";
		div.style.height = S.h+"px";
		this.mask = div;
	}
	this.updateMask = function(){
		var S = new MyScreen();
		S = S.ScreenSize();
		this.mask.style.width = S.w+"px";
		this.mask.style.height = S.h+"px";
	}
	this.switchMask = function(v){
		if(v==""){
			v = this.mask.style.display=="none"?"block":"none";		
		}
		if(this.mask){
			this.mask.style.display = v;
		}
	}
	
	this.getPosi = function(o){
		var top=0;
		var left=0;
		var width=o.offsetWidth;
		var height=o.offsetHeight;
		while (o.offsetParent) {
			top += o.offsetTop;
			left += o.offsetLeft;
			o = o.offsetParent;
		}
		return {"top":top,"left":left};
	}
	
	this.mouseCoords = function(e){
		e = $EU.getEvent(e);
		if(e.pageX || e.pageY){
			return {x:e.pageX, y:e.pageY};
		}
		return {
			x:e.clientX + document.body.scrollLeft - document.body.clientLeft,
			y:e.clientY + document.body.scrollTop  - document.body.clientTop
		};		
	}
	

	this.getScrollTop = function(o){
		var h = 0;
		while(o.parentNode){
			if(o.parentNode.scrollTop!=undefined){
				h+= o.parentNode.scrollTop;
			}
			o = o.parentNode;
		}
		return h;
	}
	

	this.getStyle = function(o,v,b){
		if(!b){
			b = client.mybrowser.browser;
		}
		
		if(b=="ie"){
			return o.currentStyle[v];
		}
		else{
			return document.defaultView.getComputedStyle(o,null).getPropertyValue(v);
		}
	}
	
	this.GoodBt = function(o,aCN,aBtStatus,title){
		o.setAttribute("over",aBtStatus[1]);
		o.setAttribute("out",aBtStatus[3]);
		o.setAttribute("down",aBtStatus[5]);
		o.setAttribute("up",aBtStatus[7]);
		o.setAttribute("click",aBtStatus[9]);
		o.className = aCN[0];	
		o.onmouseover = function(){
			if(o.getAttribute("over")!="1"){return;}
			o.className = aCN[1];
		}
		o.onmouseout = function(){
			if(o.getAttribute("out")!="1"){return;}
			o.className = aCN[2];
		}
		o.onmousedown = function(){
			if(o.getAttribute("down")!="1"){return;}
			o.className = aCN[3];
		}
		o.onmouseup = function(){
			if(o.getAttribute("up")!="1"){return;}
			o.className = aCN[4];
		}
	}
}
var ui = new UI();


function DragDrop(){
	var drago = null;
	var followMove = null;
	var mo=null;
	var margin = 0;
	var arrBox = [];
	var arrPageBox = [];
	var tempNode = document.createElement("div");
	var copyNode = document.createElement("div");
	tempNode.className = "TempNode";
	copyNode.className = "CopyNode";
	
	var iMouseClickPosition_Y = 0;
	
	

	var doBox = function(e){
		arrBox = [];
		arrPageBox = [];
		var PN = $("PageContainer").childNodes;
		var IN = null;
		var n = 0;
		var i=0;
		for(var n=0;n<PN.length;n++){
			arrPageBox[n]	 = [];
			arrPageBox[n][0] = PN[n];
			arrPageBox[n][1] = ui.getPosi(arrPageBox[n][0]);		
			arrPageBox[n][2] = arrPageBox[n][1].left + arrPageBox[n][0].offsetWidth;
			arrPageBox[n][3] = arrPageBox[n][1].top + arrPageBox[n][0].offsetHeight;
			IN = PN[n].childNodes;
			for(var j=1;j<IN.length;j++){
				arrBox[i]	 = [];
				arrBox[i][0] = IN[j];
				arrBox[i][1] = ui.getPosi(arrBox[i][0]);		
				arrBox[i][2] = arrBox[i][1].left + arrBox[i][0].offsetWidth;
				arrBox[i][3] = arrBox[i][1].top + arrBox[i][0].offsetHeight;
				i++
			}
		}
		
	};
	
	var closeItem = function(e){
		if((followMove.parentNode!=tempNode.parentNode)&&(tempNode.parentNode)){
			moveNode(followMove,tempNode.parentNode,getDir(followMove.parentNode,tempNode.parentNode));
		}
		followMove.style.position = "static";
		followMove.className = followMove.className.replace(" shadow","");
		try{
			tempNode.parentNode.removeChild(tempNode);
		}
		catch(ee){}
		copyNode.parentNode.removeChild(copyNode);
	};

	var moveItem=function(e){
		if(!drago){return;}
		e = $EU.getEvent(e);		
		var ep = ui.mouseCoords(e);
		var dir=ep.y>iMouseClickPosition_Y?-1:1;
		var ot = getMouseObj(ep.x,ep.y+ui.getScrollTop(drago),arrBox);
		if(ot){		
			dir<0?ot.appendChild(tempNode):ot.insertBefore(tempNode,ot.firstChild);
		}
		else{
			ot = getMouseObj(ep.x,ep.y+ui.getScrollTop(drago),arrPageBox);
			if(ot){
				if((ot.childNodes.length==1)&&(ot.id.indexOf("PageBox")==0)){
					ot.appendChild(tempNode);
				}
			}
			else{
				try{tempNode.parentNode.removeChild(tempNode);}catch(ee){};
			}
		}
	};
	
	var getDir = function (so,to){
		if(so.parentNode!=to.parentNode){
			so = so.parentNode;
			to = to.parentNode;
		}
		var sp,tp;
		var i=0;
		var firstChild = so.parentNode.firstChild;
		while(firstChild){
			if(firstChild==so){
				sp = i;	
			}
			else if(firstChild==to){
				tp = i;
			}
			firstChild = firstChild.nextSibling;
			i++;
		}
		return sp-tp;
	};
	
	var getMouseOffset = function (target, e){
		var docPos    = ui.getPosi(target);
		var mousePos  = ui.mouseCoords($EU.getEvent(e));
		return {x:mousePos.x - docPos.left, y:mousePos.y - docPos.top};
	};
	
	

	var getMouseObj=function(eX,eY,arr){
		for(var i=0;i<arr.length;i++){
			if(MouseInObj(eX,eY,arr[i][1].left,arr[i][1].top,arr[i][2],arr[i][3])){
				return arr[i][0];
			}
		}
		return null;
	};

	var MouseInObj = function(eX,eY,x1,y1,x2,y2){
		if((eX<x1)||(eX>x2)||(eY<y1)||(eY>y2)){
			return false;	
		}
		return true;
	};
	
	
	this.omm = function(e){
		if(drago){
			e = $EU.getEvent(e);
			followMove.style.top = (e.clientY-mo.y-margin)+"px";
			followMove.style.left = (e.clientX-mo.x-margin)+"px";	
			if(drago.getAttribute("Drop")=="yes"){
				moveItem(e);
			}
		}
	};
	this.omu = function(e){
		if(drago){
			if(drago.getAttribute("Drop")=="yes"){
				closeItem(e);
			}
			followMove = null;
			drago = null;	
		}
	};
	
	$EU.addHandler(document,"mousemove",this.omm);
	$EU.addHandler(document,"mouseup",this.omu);

	this.createDrag = function(o,followo,blnDrop,mouseDownfn,mouseUpfn){
		o.onmousedown = function(event){
			DragDrop.mouseDownfn = mouseDownfn;
			DragDrop.mouseUpfn = mouseUpfn;
			if(!eval(DragDrop.mouseDownfn)){
				return;	
			}
			drago = o;
			followMove = followo;
			if(client.mybrowser.browser=="ie"){
				margin = parseInt(ui.getStyle(followMove,"marginTop").replace("px",""),null);
			}
			else{
				margin = parseInt(ui.getStyle(followMove,"margin-top").replace("px",""),null);
			}
			
			if(isNaN(margin)){
				margin = 0;	
			}
			mo = getMouseOffset(followMove,event);
			mo.y += ui.getScrollTop(followMove);
			iMouseClickPosition_Y = ui.mouseCoords(event).y;
			if(blnDrop){
				copyNode.style.height = followMove.offsetHeight+"px";
				followMove.parentNode.insertBefore(copyNode,followMove);
				followMove.style.position = "absolute";
				followMove.style.top = iMouseClickPosition_Y+"px";
				drago.setAttribute("Drop","yes");
				doBox();
				followMove.className = followMove.className+" shadow";
			}
			return false;
		}
	}
	this.doBoxStr = function(sInput){
		sBox = sInput;
	}
	var moveNode=function(MoveNode,MoveTo,Dir){
		try{
			tempNode.parentNode.removeChild(tempNode);
		}
		catch(ee){}
		if((MoveTo.childNodes.length==1)&&(MoveTo.id.indexOf("PageBox")==0)){
			MoveTo.appendChild(MoveNode.parentNode.parentNode.removeChild(MoveNode.parentNode));	
		}
		else{
			if(Dir>0){
				MoveTo.parentNode.insertBefore(MoveNode.parentNode.parentNode.removeChild(MoveNode.parentNode),MoveTo);	
			}
			else{
				if(MoveTo.parentNode){
					MoveTo.parentNode.insertBefore(MoveNode.parentNode.parentNode.removeChild(MoveNode.parentNode),MoveTo.nextSibling);
				}
			}
		}
		eval(DragDrop.mouseUpfn);
		
	};
	
	this.doParent = function(o){
		parentNode = o;
	}
	
	
	
}

function GoodWin(sIDPrefix,oContent,oParent,sWinTitle,aSize,aWinStatus,blnMask,fn,blnFullWin){
	this.createObj = function(id,pNode,cn,css,stitle){
		var tag = null;
		try{
			tag = document.createElement("<div class='"+cn+"' id='"+id+"' style='"+css+"'></div>"); 
		}
		catch(e){
			tag = document.createElement("div");
			tag.id = id;
			tag.className = cn;
			tag.setAttribute("style",css);
		}
		if(typeof stitle!="undefined"){tag.title = stitle;}
		pNode.appendChild(tag);
		return tag;
	}
	
	var aStyle = [];
	aStyle["OQSS_Win"] = ["OQSS_Win","height:25px;"];
	aStyle["OQSS_WinBody"] = ["OQSS_WinBody","height:25px;"];
	aStyle["Bar"] = ["Bar",""];
	aStyle["OQSS_WinHead"] = ["","float:right"];
	aStyle["OQSS_WinTitle"] = ["OQSS_WinTitle",""];
	aStyle["MaxSizeBt"] = ["MaxSizeBt",""];
	aStyle["FloatWin"] = ["FloatWin",""];
	aStyle["close"] = ["close",""];
	aStyle["OQSS_WinContent"] = ["OQSS_WinContent",""];
	aStyle["OQSS_WinFoot"] = ["OQSS_WinFoot",""];
	aStyle["ChangeSizeBt"] = ["SizeBt",""];
	
	aStyle["OQSS_Win"][1] += ";display:"+aWinStatus[0];
	if(aWinStatus[2] == "absolute"){
		aStyle["OQSS_Win"][0] = "OQSS_Win shadow";	
		aStyle["OQSS_Win"][1] += ";top:30px;left:30px;position:absolute";
		aStyle["FloatWin"][0] = "StopWin";
		aStyle["OQSS_WinFoot"][1] =aWinStatus[8][3]=="1"?"display:none":"";
	}
	else{
		aStyle["OQSS_WinFoot"][1] = "display:none";
	}
	
	
	var aWinBt = aWinStatus[8].split("");
	aStyle["MaxSizeBt"][1] =aWinBt[0]=="1"?"display:none":"";
	aStyle["FloatWin"][1] =aWinBt[1]=="1"?"display:none":"";
	aStyle["close"][1] =aWinBt[2]=="1"?"display:none":"";
	aStyle["ChangeSizeBt"][1] =aWinBt[3]=="1"?"display:none":"";
	
	var aText = ["关闭窗口","最小化","最大化","浮动窗口","固定窗口"];
	var sMinHeight = "23px";
	var oWin = this.createObj(sIDPrefix+"Name",oParent,aStyle["OQSS_Win"][0],aStyle["OQSS_Win"][1]);
	var oHead = this.createObj(sIDPrefix+"Head",oWin,aStyle["Bar"][0],"");
	var oBody = this.createObj(sIDPrefix+"Body",oWin,aStyle["OQSS_WinBody"][0],aStyle["OQSS_WinBody"][1]);
	var oWinTitle = this.createObj(sIDPrefix+"Title",oHead,aStyle["OQSS_WinTitle"][0],"");
	var oToolBar  = this.createObj(sIDPrefix+"ToolBar",oHead,"",aStyle["OQSS_WinHead"][1]);
	var oMinSizeBt = this.createObj(sIDPrefix+"MinBt",oToolBar,aStyle["MaxSizeBt"][0],aStyle["MaxSizeBt"][1],aText[1]);
	var oFloatBt = this.createObj(sIDPrefix+"FloatBt",oToolBar,aStyle["FloatWin"][0],aStyle["FloatWin"][1],aText[3]);
	var oCloseBt = this.createObj(sIDPrefix+"CloseBt",oToolBar,aStyle["close"][0],aStyle["close"][1],aText[0]);
	var oContentArea = this.createObj(sIDPrefix+"Content",oBody,aStyle["OQSS_WinContent"][0],aStyle["OQSS_WinContent"][1]);
	var oFoot = this.createObj(sIDPrefix+"Foot",oBody,aStyle["OQSS_WinFoot"][0],aStyle["OQSS_WinFoot"][1]);
	var oChangeSizeBt = this.createObj(sIDPrefix+"ChangeSizeBt",oFoot,aStyle["ChangeSizeBt"][0],aStyle["ChangeSizeBt"][1]);
	GoodWin.prototype.zIndex = 1234;
	oWinTitle.innerHTML = sWinTitle;
	oWin.style.zIndex = GoodWin.prototype.zIndex;

	var drago = null;
	var StartPosi = null;
	var mo = null;	
	oContentArea.appendChild(oContent.parentNode.removeChild(oContent));
	if(typeof(GoodWin.prototype.mask)!="object"){
		var oMask = document.createElement("div");
		oMask.className = "OQSS_Mask";
		oMask.style.zIndex = GoodWin.prototype.zIndex-1;
		oMask.style.display = "none";
		document.body.appendChild(oMask);
		GoodWin.prototype.mask =  oMask; 
	}
	
	this.fullWin = function(o){
		var S = new MyScreen();S = S.ScreenSize();
		o.style.width = S.w + "px";
		o.style.height = S.h + "px";
		o.style.top = "0px";
		o.style.left = "0px";
		aSize[2] = S.w;
		aSize[3] = S.h;
	}
	
	
	
	
	this.switchMask = function(v){
		
		if(typeof(v)=="undefined"){
			GoodWin.prototype.mask.style.display = GoodWin.prototype.mask.style.display=="none"?"block":"none";
		}
		else{
			GoodWin.prototype.mask.style.display = v;
		}
	}
	GoodWin.prototype.fullWin = function(o){
		var S = new MyScreen();S = S.ScreenSize();
		var Height = parseInt(S.h)< document.body.scrollHeight?document.body.scrollHeight: parseInt(S.h);
		o.style.width = S.w + "px";
		o.style.height = Height + "px";
		o.style.top = "0px";
		o.style.left = "0px";
		aSize[2] = S.w;
		aSize[3] = S.h;
	}
	this.switchWin = function(e){
		var sTemp = oWin.style.display=="none"?"block":"none";
		if((aWinStatus[3][0]=="1")&&(sTemp=="none")){
			alert("不允许关闭")
			return;
		}
		if((aWinStatus[3][1]=="1")&&(sTemp=="block")){
			alert("不允许打开")
			return;
		}
		GoodWin.prototype.fullWin(GoodWin.prototype.mask);
		GoodWin.prototype.zIndex++;	
		GoodWin.prototype.mask.style.zIndex = GoodWin.prototype.zIndex;
		GoodWin.prototype.zIndex++;	
		oWin.style.zIndex =GoodWin.prototype.zIndex;
		oWin.style.display = sTemp;
		if(this.v="center"){
			ui.centerObj(oWin,0,0);
		}
		if(typeof(this.fn)!="undefined"){
			eval(this.fn);
		}
		if(blnMask){
			GoodWin.prototype.mask.style.display = sTemp;
			ui.centerObj(oWin,0,0);
		}
		eval(fn);
	}
	
	
	this.floatWin = function(){
		if(oFloatBt.className=="StopWin"){
			if(aWinStatus[5][1]=="1"){
				alert("不允许静态");
				return;
			}
			oWin.style.position = "static";
			oFloatBt.className="FloatWin";
			oFloatBt.title = aText[3];
			oWin.className = "OQSS_Win";
			oWin.style.height = (getSpace(oParent,oWin)-2)+"px";
			oWin.style.width = "100%";
			oFoot.style.display = "none";
			minWin();
		}
		else{
			if(aWinStatus[5][0]=="1"){
				alert("不允许浮动");
				return;
			}
			
			oWin.style.position = "absolute";
			oFloatBt.className="StopWin";
			oFloatBt.title = aText[4];
			oWin.className = "shadow OQSS_Win";
			if(aWinStatus[8][3]!="1"){
				oFoot.style.display = "block";
			}
			maxWin();
			ui.centerObj(oWin,0,0);
			
		}
		eval(fn);
		
	}
	
	oWin.onmousedown = function(){
		GoodWin.prototype.zIndex++;	
		GoodWin.prototype.mask.style.zIndex = GoodWin.prototype.zIndex;
		GoodWin.prototype.zIndex++;	
		oWin.style.zIndex =GoodWin.prototype.zIndex;
	}
	
	
	this.minmaxWin  = function(){
		oMinSizeBt.className=="MinSizeBt"?minWin():maxWin();
	}
	var minWin = function(){

		if(aWinStatus[4][0]=="1"){
			alert("不允许最小化")
			return;
		}

		oMinSizeBt.className = "MaxSizeBt";
		oWin.style.height = sMinHeight;
		oBody.style.display = "none";
		oMinSizeBt.title = aText[2];
	}
	var maxWin = function(){
		if(aWinStatus[4][1]=="1"){
			alert("不允许最大化")
			return;
		}
		oContent.style.display = "block";
		oMinSizeBt.className = "MinSizeBt";	
		oBody.style.display = "block";
		if(oWin.style.position!="absolute"){
			var nodeList = oWin.parentNode.childNodes;
			for(var i=0;i<nodeList.length;i++){
				if((nodeList[i]!=oWin)&&(nodeList[i].style.position!="absolute")&&(nodeList[i].style.display!="none")){
					nodeList[i].style.height = sMinHeight;
					nodeList[i].childNodes[1].style.display = "none";
					nodeList[i].childNodes[0].childNodes[1].childNodes[0].className = "MaxSizeBt";
				}
			}
			var iTempHeight = (getSpace(oParent,oWin)-2);
			oWin.style.height = iTempHeight+"px";
			oWin.style.width = "100%";
			oMinSizeBt.className = "MinSizeBt";
			oBody.style.display = "block";
			oMinSizeBt.title = aText[2];
			oBody.style.height = (iTempHeight-oHead.offsetHeight)+"px";
			oContentArea.style.height = oBody.style.height;
		}
		else{
			oWin.style.height = (oWin.getAttribute("OldHeight")==null?aSize[3]:oWin.getAttribute("OldHeight"))+"px";
			oWin.style.width = (oWin.getAttribute("OldWidth")==null?aSize[2]:oWin.getAttribute("OldWidth"))+"px";
			oBody.style.height = "100%";
		}
		oMinSizeBt.title = aText[1];
	}
	var minmaxWin = function(){
		oMinSizeBt.className=="MinSizeBt"?minWin():maxWin;
	}
	
	var getSpace = function(oP,oExclude){
		var nodeList = oP.childNodes;
		var iHeight = 0;
		for(var i=0;i<nodeList.length;i++){
			if((nodeList[i].style.position!="absolute")&&nodeList[i]!=oExclude){
				iHeight += nodeList[i].offsetHeight;
			}
		}
		return oP.offsetHeight-iHeight;
	}
	
	this.omm = function(e){
		if((drago)&&(aWinStatus[6]=="0")){
			e = $EU.getEvent(e);
			ChangeWinSize(oWin,StartPosi,e,100,50,800,500);
		}
	}
	this.omu = function(){
		if(drago){
			drago = null;	
		}
	}
	
	oChangeSizeBt.onmousedown = function(e){
		e = $EU.getEvent(e);
		drago = this;
		mo = getMouseOffset(drago,e);
		mo.y += ui.getScrollTop(oWin);
		StartPosi = ui.getPosi(oWin);
		return false;
	}
	
	function getMouseOffset (target, e){		
		var oPos    = ui.getPosi(target);
		var mPos  = ui.mouseCoords(e);
		return {x:oPos.left + target.offsetWidth - mPos.x  , y:oPos.top+target.offsetHeight-mPos.y};
	}
	
	var ChangeWinSize=function(ChangeObj,refPosi,e){
		var px = e.clientX - refPosi.left;
		var py = e.clientY - refPosi.top;		
		px += mo.x;
		py += mo.y;
		px = px>aSize[2]?aSize[2]:px;
		px = px<aSize[0]?aSize[0]:px;
		py = py>aSize[3]?aSize[3]:py;
		py = py<aSize[1]?aSize[1]:py;
		ChangeObj.style.width = px+"px";
		ChangeObj.style.height = py+"px";
		ChangeObj.setAttribute("OldHeight",py);
		ChangeObj.setAttribute("OldWidth",px);
	}
	
	
	
	$EU.addHandler(document,"mousemove",this.omm);
	$EU.addHandler(document,"mouseup",this.omu);	
	$EU.addHandler(oMinSizeBt,"click",this.minmaxWin);
	$EU.addHandler(oHead,"dblclick",this.minmaxWin);
	$EU.addHandler(oCloseBt,"click",this.switchWin);
	$EU.addHandler(oFloatBt,"click",this.floatWin);
	
	

	var dd = new DragDrop();
	if(aWinStatus[7]=="0"){
		dd.createDrag(oHead,oWin,false,true,"");
	}
	
	aWinStatus[1]=="0"?minWin():maxWin();	
	if(blnFullWin){
		maxWin();
		this.fullWin(oWin);	
	}

}

function msgBox(){
	(this.o = function(){
		var div = document.createElement("div");
		div.className = "MsgTips";
		document.body.appendChild(div);
		ui.centerObj(div,0,0);
		return div;
	}());
}
msgBox.prototype = {
	constructor:msgBox,
	openmsg:function(sMsg,oRef){
		this.o.innerHTML = sMsg;
		var P = ui.getPosi(oRef);
		this.o.style.top = (P.top+oRef.offsetHeight-ui.getScrollTop(oRef))+"px";
		this.o.style.left = P.left+"px";
		this.o.style.display = "block";
	},
	closemsg:function(){
		this.o.innerHTML = "";
		this.o.style.display = "none";	
	},
	switchmsg:function(sMsg,oRef){
		this.o.innerHTML = sMsg;
		var P = ui.getPosi(oRef);
		this.o.style.top = (P.top+oRef.offsetHeight-ui.getScrollTop(oRef))+"px";
		this.o.style.left = P.left+"px";
		this.o.style.display = this.o.style.display=="none"?"block":"none";

	}
}

function GoodPage(iPageNo,iPageSize,iPageNum,iRecordCount,fn){
	var a = [];
	var iBigPage = 5;
	var Start = parseInt((iPageNo-1)/iBigPage)*iBigPage+1;
	Start = Start<=1?1:Start;
	var End = parseInt((iPageNo-1)/iBigPage)*iBigPage+iBigPage;
	End = End>iPageNum?iPageNum:End;
	a.push("<div class='"+(iPageNo>1?"FirstPage":"FirstPageDis")+"' onclick='"+fn.replace("$PageNo",1)+"' title='第一页'></div>");
	a.push("<div class='"+(iPageNo>1?"PreviousPage":"PreviousPageDis")+"' onclick='"+fn.replace("$PageNo",iPageNo-(iPageNo>1?1:0))+"' title='上一页'></div>");
	for(var i=Start;i<=End;i++){
		a.push("<div class='"+(i==iPageNo?"CurrPage":"NormalPage")+"'  onclick='"+fn.replace("$PageNo",i)+"' title='第"+i+"页'>"+i+"</div>");	
	}
	if(End<iPageNum){
		a.push("<div  onclick='"+fn.replace("$PageNo",i)+"' title='' class='NormalPage'>...</div>");
	}
	a.push("<div class='"+(iPageNo<iPageNum?"NextPage":"NextPageDis")+"' onclick='"+fn.replace("$PageNo",iPageNo+(iPageNo<iPageNum?1:0))+"' title='下一页'></div>");
	a.push("<div class='"+(iPageNo<iPageNum?"LastPage":"LastPageDis")+"' onclick='"+fn.replace("$PageNo",iPageNum)+"' title='最未页'></div>");
	return a.join("");
}

function oqssmenu(o){
	var menucontent = null;
	this.t = null;
	var openMenu = function(){
		menucontent.style.display = menucontent.style.display=="none"?"block":"none";
	};
	var domenu = function(e){
		e = $EU.getEvent(e);
		this.t = $EU.getTarget(e);
		if(! checkIsParent(this.t)  ){
			menucontent.style.display = "none";
		}
	};
	var checkIsParent = function(t){
		var isPar = false;
		var Temp = null;
		while(t){
			if(t.parentNode==o){
				return true;	
			}
			t = t.parentNode;
		}
		return false;
	};
	var n = 0;
	var queryMenuContent = function(r){
		n++;
		if(r.getAttribute("IsMenu")=="Yes"){
			return r;	
		}
		var nl = r.childNodes;
		for(var i=0;i<nl.length;i++){
			if(nl[i].nodeType==1){
				if(nl[i].getAttribute("IsMenu")=="Yes"){
					return nl[i];
				}
			}
		}
		for(var i=0;i<nl.length;i++){
			if(nl[i].nodeType==1){
				if(queryMenuContent(nl[i])){
					return nl[i];
				}
			}
		}
		return null;
	};
	this.init = function(){
		menucontent = queryMenuContent(o);
		$EU.addHandler(o, "click", openMenu);
		$EU.addHandler(document, "mousemove", domenu);
	}();	
}
